#include "pch.h"
#include "units_test.h"

#include <math/vector4.hpp>
#include <math/units.hpp>




typedef math::constants<float>       constants;
typedef units::scalar<float>         scalar;
typedef units::mass<float>           mass;
//typedef time<float>                  time;
typedef units::length<float>         length;
typedef units::velocity<float>       velocity;
typedef units::acceleration<float>   acceleration;
typedef units::force<float>          force;
typedef units::angle<float>          angle;

using math::vector2;




static const float precision = 0.001f;




void test_angle()
{
	angle a1 = angle::degrees(180);
	angle a2 = angle::radians(constants::pi());

	ASSERT_EQUAL_DELTA( constants::pi(), a1.value(), precision );
	ASSERT_EQUAL_DELTA( constants::pi(), a2.value(), precision );

	a1 /= scalar(2);
	ASSERT_EQUAL_DELTA( constants::pi_half(), a1.value(), precision );

	a1 *= scalar(4);
	ASSERT_EQUAL_DELTA( constants::pi_double(), a1.value(), precision );
}
///////////////////////////////////////////////////////////////////////////////////////////////////

void test_vector()
{
	typedef vector2<length> position;

	position p( length::meters(10), length::meters(0) );
	//p.lengthSquared();
}
///////////////////////////////////////////////////////////////////////////////////////////////////




void runUnits()
{
	cute::suite s;

	s.push_back( cute::test( test_angle,   "units::angle<float>" ) );

	test_vector();

	cute::ide_listener lis;
	cute::makeRunner( lis )( s, "Units Test" );
}
///////////////////////////////////////////////////////////////////////////////////////////////////
